var columns = [{checkbox:true},
               {field:"id",title:"id",visible:false},
               {field:"deptName",title:"群组名称"},
               {field:"deptDesc",title:"群组描述"},
               {field:"company.companyName",title:"公司名称"},
              {field:"createTime",title:"创建时间",formatter:
             		function(value,row,index){
          		return isEmpty(value) ? null: formatDate(new Date(value), "yyyy-MM-dd hh:mm:ss");
          	}},
          	 {field:"updateTime",title:"修改时间",formatter:
          		function(value,row,index){
       		return isEmpty(value) ? null: formatDate(new Date(value), "yyyy-MM-dd hh:mm:ss");
       	}}
              
            
   		];
function queryParams(params) {
	var param = {
			pageNumber : params.pageNumber,
			pageSize : params.pageSize,
			"cname" :$('.search input').val()
		};
	return param;
}
var dept_table = $('#dept_table');//通过table id获取需要初始化的table
//初始化的table
initTable(dept_table,$('#user_toolbar'),'dept/list',columns,queryParams,'zh-CN',true);

//给搜索框添加提示
$('.search input').attr("placeholder","搜索群组名称");


function btnDel(){
	var ids = getSelections(dept_table,'id');
	if (ids.length==0) {
		layer.msg("请选择要删除的记录", {icon:0});
	}else{
		layer.confirm('确定删除所选记录？',{icon:3},function (index) {
			$.post('dept/delete', {
        	    "json": JSON.stringify(ids)
        	},
        	function(json) {
        	    if (json.status == 0) {
        	    	refreshDelTable(dept_table, ids.length);
        	    }
        	    layer.msg(json.message);
        	});
			layer.close(index);
		});
	}
}
function btnEdit(){
	var ids = getSelections(dept_table,'id');
	if (ids.length == 1) {
	 	loadPage('dept/'+ids.toString()+'/select');
	}else{
		layer.msg("你没有选择行或选择了多行数据", {icon:0});
	}
}